
/**
\file
Definition of the sun::lua::signals_lua_interface function.
\author Sean Tromans
*/

#include <sun_pre_compiled.hpp>
#include <sun/lua/signals/signals.hpp>

SUN_PUSH_DISABLE_SIGNALS_WARNINGS( )
#include <boost/signals2.hpp>
SUN_POP_DISABLED_WARNINGS( )

#if !defined(SUN_DISABLE_LUA)
#include <sun/lua/lua.hpp>
#endif

namespace sun
{

	namespace lua
	{

		/**
		Exposes the minimum interface required for lua to interact with the boost::signals library used within the engine.
		@param L The lua state being initialsed.
		\author Sean Tromans
		*/
		void signals_lua_interface( lua_State * L )
		{
#if !defined(SUN_DISABLE_LUA)
			luabind::module( L, "sun" )
			[
				luabind::class_<boost::signals2::connection>( "connection" )
					.property( "connected",	&boost::signals2::connection::connected )
					.property( "blocked",	&boost::signals2::connection::blocked )
					.def( "disconnect",		&boost::signals2::connection::disconnect ),

				luabind::class_<boost::signals2::shared_connection_block>( "shared_connection_block" )
					.def( luabind::constructor<>( ) )
					.def( luabind::constructor<boost::signals2::shared_connection_block&>( ) )
					.def( luabind::constructor<boost::signals2::connection const &>( ) )
					.def( luabind::constructor<boost::signals2::connection const &, bool>( ) )
					.def( "block",			&boost::signals2::shared_connection_block::block )
					.def( "unblock",		&boost::signals2::shared_connection_block::unblock )
					.property( "blocking",	&boost::signals2::shared_connection_block::blocking )
					.property( "connection", &boost::signals2::shared_connection_block::connection )
			];
#else
			NMN_UNUSED( L );
#endif
		}

	};

};
